home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / ExampleB / exampleBwnd.h < prev    next >
C/C++ Source or Header  |  2001-10-08  |  7KB  |  197 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29. // ===========================================================================
  30. //
  31. //    NULLSOFT WASABI SDK EXAMPLE PROJECTS
  32. //
  33. //      File:     ExampleBWnd.h
  34. //
  35. //!##   Purpose:  Define the Component's main window class for our example
  36. //
  37. //      Requires: Please read Example1wnd.h first.
  38. //
  39. //      Notes:    A note on the comments in this document:
  40. //
  41. //                Notes that begin with *** are important notes that everyone
  42. //                needs to read.  The other comments assist readability or
  43. //                explain the thinking behind sections of code which may not
  44. //                be immediately obvious to the novice programmer.
  45. //
  46. //                Or I'm just typing to hear myself clickyclack.
  47. //
  48.  
  49.  
  50. #ifndef _EXAMPLEBWND_H
  51. #define _EXAMPLEBWND_H
  52.  
  53. //
  54. // This is our parent class: TabSheet from "../common/tabsheet.h"
  55. // If you are including more than just the header to your parent class
  56. // in your headers, you need to think carefully about why you are doing so.
  57. #include "../common/tabsheet.h"
  58.  
  59. //
  60. //  Forward References
  61. class EditWnd;
  62. class TreeWnd;
  63. class UrlGrab;
  64. class TextBar;
  65.  
  66. //
  67. //  Class Definition
  68. #define EXAMPLEBWND_PARENT TabSheet
  69. class ExampleBWnd : public EXAMPLEBWND_PARENT {
  70. public:
  71.  
  72.   //
  73.   // These are the ID values that we give to our
  74.   // buttons in order to know what the hell got
  75.   // pushed when we get told something got pushed.
  76.   typedef enum {
  77.     EXB_PREVIOUS      = 0,
  78.     EXB_PLAY          = 1,
  79.     EXB_PAUSE         = 2,
  80.     EXB_STOP          = 3,
  81.     EXB_NEXT          = 4,
  82.     EXB_XML_GO        = 5,
  83.     //
  84.     NUM_EXB_NOTIFY
  85.   } ExampleBWindowNotifyIDs;
  86.  
  87.   //
  88.   // These constants control the number of pixels to offset the UI Objects
  89.   // from the top-left of their container window (see the .CPP file)
  90.   typedef enum {
  91.     EXB_LEFT_OFFSET   = 11,
  92.     EXB_TOP_OFFSET    = 10,
  93.     EXB_BUTTON_WIDTH  = 60,
  94.     EXB_BUTTON_HEIGHT = 25,
  95.     EXB_BUTTON_SPACER = 3,
  96.     EXB_XML_BUFFSIZE  = 2000,
  97.     EXB_TIMER_ID      = 0xD0D0D0D0,
  98.     EXB_TIMER_DUR     = 200,
  99.     //
  100.     NUM_EXB_VALUES
  101.   } ExampleBValues;
  102.  
  103.   //
  104.   // These constants describe the different states of downloading a file
  105.   // using UrlGrab and are used to control the state of the display.
  106.   typedef enum {
  107.     EXB_DOWNLOAD_WAIT   = 0,
  108.     EXB_DOWNLOAD_READY  = 1,
  109.     EXB_DOWNLOAD_ERROR  = 2,
  110.     //
  111.     NUM_EXB_DOWNLOAD_STATES
  112.   } ExampleBDownloadStates;
  113.  
  114. public:
  115.  
  116.   // We commit the tasks of 1) Instantiation and 2) Assembly in the 
  117.   // CONSTRUCTOR of the containment class.  The third primary task to occur 
  118.   // before normal framelooped behaviour, Initialization, occurs AUTOMATICALLY
  119.   // for ALL underived contained objects by the baseclass onInit() handler.
  120.   ExampleBWnd();
  121.   // So, obviously, if you override your onInit() method, you'd best be 
  122.   // calling your parentclass too, unless you've got a damn good reason not to
  123.  
  124.  
  125.   // =========================================================================
  126.   //
  127.   //  Methods used primarily by ExampleBWnd.cpp
  128.   //
  129.   // Go create all the windows into the tabsheet.
  130.   int createChildWindows();     
  131.   // Make some fun buttons that link to the core controls.
  132.   int createCoreButtonsSheet(); 
  133.  
  134.  
  135.   // =========================================================================
  136.   //
  137.   //  Methods used primarily by ExampleBFrameWnd.cpp
  138.   //
  139.   // Make some frames and process some XML.  Send urls to the minibrowser.
  140.   int createFramesSheet();  
  141.   // Use the string contained in the edit field as an url to get an XML document.
  142.   void startURLDownload();
  143.   // Fetch the string from the edit field in a more friendly manner than buffer copies.
  144.   const String getXMLURL();
  145.   // Process the state of our XML download.
  146.   void pollDownloadState();
  147.   // Put up the error box into the display region.
  148.   void displayDownloadError();
  149.   // Put up the 'Please wait' box into the display region
  150.   void displayDownloadWait();
  151.   // Parse the file.  Setup the display.
  152.   void displayXMLData();
  153.   // Set the text in the display field.
  154.   void displayText(const char * text);
  155.  
  156.  
  157.   // =========================================================================
  158.   //
  159.   //  Methods used by all primary modules in this project
  160.   //
  161.   // A centralized notification handler, that strictly uses the
  162.   // msg and param values, not pointers.
  163.   int handleChildNotify (int msg, int param1, int param2);
  164.  
  165.  
  166.   // =========================================================================
  167.   //
  168.   //  Virtual methods from parent derived for this object
  169.   //
  170.   virtual int childNotify(RootWnd *which, int msg, int param1, int param2);
  171.     virtual void timerCallback(int id);
  172.     virtual int onInit();
  173.  
  174. protected:
  175.  
  176.   // =========================================================================
  177.   //
  178.   //  Data values used primarily by ExampleBFrameWnd.cpp
  179.   //
  180.   // Oh goody.  We get to carry around a fixed size buffer!  Joy!   GRUMP!
  181.   char        myXMLURLBuffer[ EXB_XML_BUFFSIZE ];
  182.   // We need to keep the pointers to some objects in order to more easily
  183.   // interact with them in a positive and supportive manner.
  184.   EditWnd *   xmlurledit;
  185.   TreeWnd *   myFrameTreeWnd;
  186.   TextBar *   myFrameTextBar;
  187.   UrlGrab *   myUrlGrab;
  188.   // Since we're downloading a file and then processing it, we set up a
  189.   // cooperatively asynchronous state machine to handle the different
  190.   // state transitions of the concept of a file download via HTTP.
  191.   // This is the variable that holds the current state of the machine.
  192.   ExampleBDownloadStates    myDownloadState;
  193.  
  194. };
  195.  
  196. #endif _EXAMPLEBWND_H
  197.